# include <stdio.h>
# include <string.h>
const char* lastnumble(char*a);
int main(){
	int n,i,j,k,x=0;
	char a[17]={0};
    char l[2]={'\0','\0'};
	scanf("%d",&n);
	for(i=0;i<n;i++){

	for(j=0;j<17;j++){
		a[j]=getchar();printf("a[%d]=%c",j,a[j]);
	}l[0]=getchar();
	printf("l[0]=%s",l[0]);
	if(strcmp(lastnumble(a),&l[0])!=0){
		for(k=0;k<17;k++){
			printf("%d",a[k]);printf("%c",l[0]);
		}x=1;
	}
	
}
	if(x==0){printf("All passed");
	} 
	return 0;
} 

const char* lastnumble(char*a){
	int s=0,count=0,i;
	int b[17]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
	for(i=0;i<17;i++){
		s+=a[i]*b[i];
		count+=b[i];
	}printf("z=%d",s/count%11);
      char m[12]={'1','0','X','9','8','7','6','5','4','3','2','\0'};
	const char*k=&m[s/count%11];
	return k;
}
